package com.example.card.transactionimplementation;

import com.example.card.CardConstant;
import com.example.card.CardDataBase;
import com.example.card.abstracttransactions.CardModifyTransaction;
import com.example.card.domain.card.Card;

public class CardBindTransaction extends CardModifyTransaction {

    public CardBindTransaction(int memberId, int id) {
        super(memberId, id);
    }

    @Override
    public void change(Card card) {
        if (CardConstant.STATUS_INIT == card.getStatus()
                || CardConstant.STATUS_NO_BIND == card.getStatus()) {
            card.setStatus(CardConstant.STATUS_NORMAL);
            CardDataBase.bindCard(memberId, id);
        } else {
            throw new RuntimeException("初始转态卡和未绑定卡才能绑定");
        }
    }


}
